# Author: Chris Moyer
from marajo.appengine.handlers import RequestHandler
from marajo.appengine.api.users import User

class AccountPage(RequestHandler):
    """
    The "My Account" page
    """

    def get(self):
        return self.display("account.tmpl")

    def post(self):
        """
        Make changes to your own account
        """
        password = self.request.POST.get("password", "")
        if password and password == self.request.POST.get("verify_password"):
            self.user.password = password
        nickname = self.request.POST.get("nickname")
        if nickname:
            self.user.nickname = nickname
        email = self.request.POST.get("email")
        if email:
            self.user.email = email
        self.user.put()
        return self.get()
